<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="en">
	<head>
	<base href="<%=basePath%>"><!-- jsp文件头和头部 -->
	<%@ include file="../../system/main/main_top.jsp"%> 
	
    <link rel="stylesheet" media="screen" type="text/css" href="static/select2-js/select2.css" />
    <style media="print" type="text/css">
		.Noprint 
		{
			display: none;
		}
	</style>
	</head>
<body>
<div class="container-fluid" id="main-container">
<div id="breadcrumbs">
	<ul class="breadcrumb">
		<li><i class="icon-home"></i> <a>统计报表</a> <span class="divider">
				<i class="icon-angle-right"></i>
		</span></li>
		<li class="active">活动报名对账单</li>
	</ul>
	<!--.breadcrumb-->
</div>
<div id="page-content" class="clearfix">
  <div class="row-fluid">
	<div class="row-fluid">
			<!-- 检索  -->
			<form action="activityEnrollStatement/list.do" method="post" name="Form" id="Form">
			<table class="Noprint">
				<tr>
					<td><input class="span10 date-picker" id="lastStart" name="lastStart" value="${pageData.lastStartShow}" type="text" data-date-format="yyyy-mm-dd" readonly="readonly" style="width:120px;" placeholder="对账时间从"/></td>
					<td><input class="span10 date-picker" id="lastEnd" name="lastEnd" value="${pageData.lastEndShow}" type="text" data-date-format="yyyy-mm-dd" readonly="readonly" style="width:120px;" placeholder="对账时间至"/></td>
					<td style="vertical-align:top;"><a class="btn btn-mini btn-light" onclick="searchStatement();" title="查询"><i id="nav-search-icon" class="icon-search"></i>查询</a></td>
					<td style="vertical-align:top;"><a class="btn btn-mini btn-light" onclick="clearCondition();" title="清空查询条件"><i id="nav-search-icon"></i>清空查询条件</a></td>
					<td style="vertical-align:top;"><a class="btn btn-mini btn-light" onclick="exportExcel();" title="导出到EXCEL"><i id="nav-search-icon" class="icon-download-alt"></i></a></td>
				</tr>
			</table>
			<!-- 检索  -->
			<div class="Noprint">
				<i class="icon-circle green"></i>温馨提示：<strong>默认显示从当前月份往前1个星期的数据</strong>
			</div>
			<table id="table_report" class="table table-striped table-bordered table-hover" style="margin-top: 10px;">
				<thead>
					<tr><th colspan="7" class="center">对账单</th></tr>
					<tr>
						<th>活动ID</th>
						<th>活动发起人名称</th>
						<th>活动发起人电话</th>
						<th>活动金额</th>
						<th>支付方式</th>
						<th>日期</th>
						<th class="center Noprint">操作</th>
					</tr>
				</thead>
										
				<tbody>
				<!-- 开始循环 -->	
				<c:choose>
					<c:when test="${not empty varList}">
						<c:forEach items="${varList}" var="var" varStatus="vs">
							<tr>
									<td>
										${var.act_id}
									</td>
									<td>
										${var.act_promotor_name}
									</td>
									<td>
										${var.act_promotor_mobile}
									</td>
									<td>
										<fmt:formatNumber type="number" value="${var.total_fee == null || var.total_fee == '' ? var.total_amount_fee : var.total_fee} " maxFractionDigits="2"/>
									</td>
									<td>
										<c:if test="${var.pay_method == '1' }">苹果支付</c:if>
										<c:if test="${var.pay_method == '2' }">支付宝支付</c:if>
										<c:if test="${var.pay_method == '3' }">微信APP支付</c:if>
										<c:if test="${var.pay_method == '7' }">微信公众号支付</c:if>
									</td>
									<td>${var.create_date}</td>
									<td class="center Noprint">
										<c:if test="${var.create_date != null}">
											<div>
												<a class='btn btn-mini btn-info' title="查看详情" onclick="view('${var.create_date}','${var.act_id }','${var.pay_method }');"><i class='icon-eye-open'></i></a>
											</div>
										</c:if>
									</td>
							</tr>
						</c:forEach>
						<!-- 
						<tr>
							<td colspan="100" class="center">您无权查看</td>
						</tr>
						 -->
					</c:when>
					<c:otherwise>
						<tr class="main_info">
							<td colspan="100" class="center" >没有相关数据</td>
						</tr>
					</c:otherwise>
				</c:choose>
				</tbody>
				<tr>
					<td>合计</td>
					<td></td>
					<td></td>
					<td><fmt:formatNumber type="number" value="${pageData.totalAmount == null || pageData.totalAmount == '' ? 0.0000 : pageData.totalAmount} " maxFractionDigits="2"/></td>
					<td></td>
					<td></td>
					<td></td>
				</tr>
			</table>
		</form>
	</div>
 	<div class="center">
		<a class="btn btn-primary Noprint" onclick="window.print()">打印</a>
	</div>
	<!-- PAGE CONTENT ENDS HERE -->
  </div><!--/row-->
	
</div><!--/#page-content-->
</div><!--/.fluid-container#main-container-->
		
		<!-- 返回顶部  -->
		<a href="#" id="btn-scroll-up" class="btn btn-small btn-inverse">
			<i class="icon-double-angle-up icon-only"></i>
		</a>
		
		<!-- 引入 -->
		<script type="text/javascript">window.jQuery || document.write("<script src='static/js/jquery-1.9.1.min.js'>\x3C/script>");</script>
		<script type="text/javascript" src="static/js/bootstrap.min.js"></script>
		<script type="text/javascript" src="static/js/ace-elements.min.js"></script>
		<script type="text/javascript" src="static/js/ace.min.js"></script>
		<script type="text/javascript" src="static/js/chosen.jquery.min.js"></script><!-- 下拉框 -->
		<script type="text/javascript" src="static/js/bootstrap-datepicker.min.js"></script><!-- 日期框 -->
		<!-- 引入 -->
		
		<script type="text/javascript">
		$(top.hangge());
		
		//检索
		function searchStatement(){
			var start = $("#lastStart").val();  
		    var end = $("#lastEnd").val();  
		    if(start != null && end != null){
		        if(end < start){  
		            alert('结束时间不能早于开始时间！');  
		            $("#lastEnd").focus();  
		            return false;  
		        }  
		          
		        var days = daysBetween(start,end);  
		        if(days>7){  
		            alert('时间跨度不能超过一个星期！');  
		            $("#lastEnd").focus();  
		            return false;  
		        }  
		    }  

			$("#Form").submit();
		}
		
		//+--------------------------------------------------    
		//| 求两个时间的天数差 日期格式为 YYYY-MM-dd     
		//+--------------------------------------------------  
		function daysBetween(DateOne,DateTwo)    
		{     
		    var OneMonth = DateOne.substring(5,DateOne.lastIndexOf ('-'));    
		    var OneDay = DateOne.substring(DateOne.length,DateOne.lastIndexOf ('-')+1);    
		    var OneYear = DateOne.substring(0,DateOne.indexOf ('-'));    
		    
		    var TwoMonth = DateTwo.substring(5,DateTwo.lastIndexOf ('-'));    
		    var TwoDay = DateTwo.substring(DateTwo.length,DateTwo.lastIndexOf ('-')+1);    
		    var TwoYear = DateTwo.substring(0,DateTwo.indexOf ('-'));    
		    
		    var cha=((Date.parse(OneMonth+'/'+OneDay+'/'+OneYear)- Date.parse(TwoMonth+'/'+TwoDay+'/'+TwoYear))/86400000);     
		    return Math.abs(cha);    
		}  
		
		//查看
		function view(create_date, act_id, pay_method){
			 top.jzts();
			 var diag = new top.Dialog();
			 diag.Drag=true;
			 diag.Title ="查看详情";
			 diag.URL = '<%=basePath%>/activityEnrollStatement/goView.do?create_date='+create_date + '&act_id=' + act_id+'&pay_method='+pay_method;
			 diag.Width = 900;
			 diag.Height = 600;
			 diag.CancelEvent = function(){ //关闭事件
				//if(diag.innerFrame.contentWindow.document.getElementById('centerOfMainFrame').style.display == 'none'){
					//window.location.href='<%=basePath%>/statement/list.do';
				//}
				diag.close();
			 };
			 diag.show();
		}
		
		function clearCondition(){
			$("#lastStart").val("");
			$("#lastEnd").val("");
		}
		</script>
		
		<script type="text/javascript">
		$(function() {
			//单选框
			$(".chzn-select").chosen(); 
			$(".chzn-select-deselect").chosen({allow_single_deselect:true}); 
			//日期框
			$('.date-picker').datepicker();
		});
		
		function exportExcel(){
			var lastStart = $("#lastStart").val();  
		    var lastEnd = $("#lastEnd").val();  
			window.location.href='<%=basePath%>/activityEnrollStatement/exportExcel.do?lastStart='+lastStart+'&lastEnd='+lastEnd;
		}
		</script>
	</body>
</html>

